﻿using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;

namespace QQSideShowCreator {
	public class ControlsProfile : IList<ControlSetting>{
		public ControlsProfile() {
			_settings = new List<ControlSetting>();
		}
		public ControlsProfile(string image_name) {
			_settings = new List<ControlSetting>();
			strImageName = image_name;
		}

		List<ControlSetting> _settings;

		#region Decimal settings for a profile, like width and height.
		/// <summary>
		/// Width of padding between two columns of pictures, in pixel.
		/// </summary>
		int horizontal_padding;
		/// <summary>
		/// Get or set width of padding between two columns of pictures, in pixel.
		/// </summary>
		public int HorizontalPadding {
			get { return horizontal_padding; }
			set { horizontal_padding = value; }
		}
		/// <summary>
		/// Height of padding between two rows of pictures, in pixel.
		/// </summary>
		int vertical_padding;
		/// <summary>
		/// Get or set height of padding between two columns of pictures, in pixel.
		/// </summary>
		public int VerticalPadding {
			get { return vertical_padding; }
			set { vertical_padding = value; }
		}
		/// <summary>
		/// Size of a fragment in a profile.
		/// </summary>
		Size fragment_size;
		/// <summary>
		/// Get or set size of a fragment in a profile.
		/// </summary>
		public Size FragmentSize {
			get { return fragment_size; }
			set { fragment_size = value; }
		}
		/// <summary>
		/// The amount of image fragments in a row
		/// </summary>
		int row_count;
		/// <summary>
		/// Get or set the amount of image fragments in a row
		/// </summary>
		public int RowCount {
			get { return row_count; }
			set { row_count = value; }
		}
		/// <summary>
		/// The amount of image fragments in a column
		/// </summary>
		int col_count;
		/// <summary>
		/// Get or set the amount of image fragments in a column
		/// </summary>
		public int ColumnCount {
			get { return col_count; }
			set { col_count = value; }
		}
		#endregion

		/// <summary>
		/// The name of the frame image resource.
		/// </summary>
		string strImageName;
		/// <summary>
		/// Get or set the name of the frame image resource
		/// </summary>
		public string ImageName {
			get { return strImageName; }
			set { strImageName = value; }
		}

		#region IList<ControlSetting> Members

		public int IndexOf(ControlSetting item) {
			return _settings.IndexOf(item);
		}

		public void Insert(int index, ControlSetting item) {
			_settings.Insert(index, item);
		}

		public void RemoveAt(int index) {
			_settings.RemoveAt(index);
		}

		public ControlSetting this[ int index ] {
			get { return _settings[ index ]; }
			set { _settings[ index ] = value; }
		}

		#endregion

		#region ICollection<ControlSetting> Members

		public void Add(ControlSetting item) {
			_settings.Add(item);
		}

		public void Clear() {
			_settings.Clear();
		}

		public bool Contains(ControlSetting item) {
			return _settings.Contains(item);
		}

		public void CopyTo(ControlSetting[] array, int arrayIndex) {
			_settings.CopyTo(array, arrayIndex);
		}

		public int Count {
			get { return _settings.Count; }
		}

		public bool IsReadOnly {
			get { throw new NotImplementedException(); }
		}

		public bool Remove(ControlSetting item) {
			return _settings.Remove(item);
		}

		#endregion

		#region IEnumerable<ControlSetting> Members

		public IEnumerator<ControlSetting> GetEnumerator() {
			return _settings.GetEnumerator();
		}

		#endregion

		#region IEnumerable Members

		IEnumerator IEnumerable.GetEnumerator() {
			return _settings.GetEnumerator();
		}

		#endregion
	}

	public class ControlSetting {
		public ControlSetting(Control ctrl) {
			_control = ctrl;
			_ctrlSize = Size.Empty;
			_ctrlLocation = Point.Empty;
			_ctrlDock = DockStyle.None;
		}

		public ControlSetting(Control ctrl, Size size, Point location, DockStyle dock) {
			_control = ctrl;
			_ctrlSize = size;
			_ctrlLocation = location;
			_ctrlDock = dock;
		}

		public Control Control { get { return _control; } }
		public Size ControlSize {
			get { return _ctrlSize; }
			set { _ctrlSize = value; }
		}
		public Point TopLeft {
			get { return _ctrlLocation; }
			set { _ctrlLocation = value; }
		}
		public DockStyle Dock {
			get { return _ctrlDock; }
			set { _ctrlDock = value; }
		}

		Control _control;
		Size _ctrlSize;
		Point _ctrlLocation;
		DockStyle _ctrlDock;
	}
}
